import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OpinionVO, OpinionForm, OpinionQuery } from '@/api/system/opinion/types';

/**
 * 查询意见反馈列表
 * @param query
 * @returns {*}
 */

export const listOpinion = (query?: OpinionQuery): AxiosPromise<OpinionVO[]> => {
  return request({
    url: '/system/opinion/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询意见反馈详细
 * @param id
 */
export const getOpinion = (id: string | number): AxiosPromise<OpinionVO> => {
  return request({
    url: '/system/opinion/' + id,
    method: 'get'
  });
};

/**
 * 新增意见反馈
 * @param data
 */
export const addOpinion = (data: OpinionForm) => {
  return request({
    url: '/system/opinion',
    method: 'post',
    data: data
  });
};

/**
 * 修改意见反馈
 * @param data
 */
export const updateOpinion = (data: OpinionForm) => {
  return request({
    url: '/system/opinion',
    method: 'put',
    data: data
  });
};

/**
 * 删除意见反馈
 * @param id
 */
export const delOpinion = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/opinion/' + id,
    method: 'delete'
  });
};
